﻿<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="false"  CodeBehind="PeiXunYingJi.aspx.cs" Inherits="Catering.Catering_Page.richang.PeiXunYingJi" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>培训应急</title>
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../../Scripts/zhezhao.js" type="text/javascript"></script>
    <link href="../../Style/center.css" rel="stylesheet" type="text/css" />
    <link href="../../Style/sysData.css" rel="stylesheet" type="text/css" />
    <link href="../../Style/zhezhao.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../../Scripts/uploader/jquery.uploadify.v2.1.0.min.js"></script>
    <script type="text/javascript" src="../../Scripts/uploader/swfobject.js"></script>
    <link type="text/css" href="../../Scripts/uploader/uploadify.css" rel="stylesheet" />
    <script language="javascript" type="text/javascript" src="../../Scripts/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#txt_pxqk_riqi").focus(function () { WdatePicker({ dateFmt: 'yyyy-MM-dd' }) });
            $("input[name='rbm']").change(function () {
                var _thisval = $(this).val();
                if (_thisval == "是") {
                    $("#Button1").attr("disabled", false);
                    $("#Button2").attr("disabled", false);
                    $("#Button3").attr("disabled", false);
                } else if (_thisval == "否") {
                    $("#Button1").attr("disabled", true);
                    $("#Button2").attr("disabled", true);
                    $("#Button3").attr("disabled", true);
                }
            });

            $("#Imgfile_peixunqingkuang").uploadify({
                'uploader': '../../Scripts/uploader/uploadify.swf',
                'script': 'Upload.aspx',
                'cancelImg': '../../Scripts/uploader/cancel.png',
                'folder': '../../UpFile',
                'queueID': 'fileQueue',
                'buttonImg': '../../Scripts/uploader/liulan.png',
                'auto': false,
                'multi': true,
                'onComplete': function fun(event, queueID, fileObj, response, data) {
                    if (response == "true") {
                        $("#hdn_pxqk_filepath").val($("#hdn_pxqk_filepath").val() + "," + fileObj.name);
                        alert("文件：" + fileObj.name + "上传成功。");
                    }
                    else if (response == "false") {
                        alert("文件上传出错！");
                    }
                },
                'onSelect': function (e, queueId, fileObj) {
                    $('#Imgfile_peixunqingkuang').uploadifyUpload();
                },
                'onCancel': function (file) {
                    
                }
            });

            $("#Imgfile_yuan").uploadify({
                'uploader': '../../Scripts/uploader/uploadify.swf',
                'script': 'Upload.aspx',
                'cancelImg': '../../Scripts/uploader/cancel.png',
                'folder': '../../UpFile',
                'queueID': 'fileQueue',
                'buttonImg': '../../Scripts/uploader/liulan.png',
                'auto': false,
                'multi': false,
                'onComplete': function fun(event, queueID, fileObj, response, data) {
                    if (response == "true") {
                        alert("文件：" + fileObj.name + "上传成功。");
                        $("#hdn_yjqk_yuan_filepath").val(fileObj.name);
                    }
                    else if (response == "false") {
                        alert("文件上传出错！");
                    }
                },
                'onSelect': function (e, queueId, fileObj) {
                    $('#Imgfile_yuan').uploadifyUpload();
                },
                'onCancel': function (file) {

                }
            });

            $("#Imgfile_jilu").uploadify({
                'uploader': '../../Scripts/uploader/uploadify.swf',
                'script': 'Upload.aspx',
                'cancelImg': '../../Scripts/uploader/cancel.png',
                'folder': '../../UpFile',
                'queueID': 'fileQueue',
                'buttonImg': '../../Scripts/uploader/liulan.png',
                'auto': false,
                'multi': false,
                'onComplete': function fun(event, queueID, fileObj, response, data) {
                    if (response == "true") {
                        alert("文件：" + fileObj.name + "上传成功。");
                        $("#hdn_yjqk_jilu_filepath").val(fileObj.name);
                    }
                    else if (response == "false") {
                        alert("文件上传出错！");
                    }
                },
                'onSelect': function (e, queueId, fileObj) {
                    $('#Imgfile_jilu').uploadifyUpload();
                },
                'onCancel': function (file) {

                }
            });

            $("#Imgfile_zongjie").uploadify({
                'uploader': '../../Scripts/uploader/uploadify.swf',
                'script': 'Upload.aspx',
                'cancelImg': '../../Scripts/uploader/cancel.png',
                'folder': '../../UpFile',
                'queueID': 'fileQueue',
                'buttonImg': '../../Scripts/uploader/liulan.png',
                'auto': false,
                'multi': false,
                'onComplete': function fun(event, queueID, fileObj, response, data) {
                    if (response == "true") {
                        alert("文件：" + fileObj.name + "上传成功。");
                        $("#hdn_yjqk_zongjie_filepath").val(fileObj.name);
                    }
                    else if (response == "false") {
                        alert("文件上传出错！");
                    }
                },
                'onSelect': function (e, queueId, fileObj) {
                    $('#Imgfile_zongjie').uploadifyUpload();
                },
                'onCancel': function (file) {

                }
            });
        });

        //添加数据
        function btn_yjqk_Add() {
            
            var txt_yjqk_mingchen = $("#txt_yjqk_mingchen").val();
            var txt_yjqk_renshu = $("#txt_yjqk_renshu").val();
            var ddl_yjqk_leibie = $("#ddl_yjqk_leibie").val();
            var hdn_yjqk_filepath = $("#hdn_yjqk_filepath").val();

            var hdn_yjqk_zongjie_filepath = $("#hdn_yjqk_zongjie_filepath").val();
            var hdn_yjqk_jilu_filepath = $("#hdn_yjqk_jilu_filepath").val();
            var hdn_yjqk_yuan_filepath = $("#hdn_yjqk_yuan_filepath").val();

            var hdn_useDate = $("#hdn_useDate").val();
            var hdn_currentClassID = $("#hdn_currentClassID").val();
            var hdn_currentGroppID = $("#hdn_currentGroppID").val();

            var _ribaobianhao = hdn_useDate + "," + hdn_currentClassID + "," + hdn_currentGroppID + ",";

            $.ajax({
                type: "Post",
                url: "PeiXunYingJi.aspx/YingJiQingKuang_Add",
                data: "{'txt_yjqk_mingchen':'" + txt_yjqk_mingchen + "','txt_yjqk_renshu':'" + txt_yjqk_renshu + "','ddl_yjqk_leibie':'" + ddl_yjqk_leibie + "','_wendang':'" + hdn_yjqk_filepath + "','_ribaobianhao':'" + _ribaobianhao + "','yuan':'" + hdn_yjqk_yuan_filepath + "','jilu':'" + hdn_yjqk_jilu_filepath + "','zongjie':'" + hdn_yjqk_zongjie_filepath + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "ok") {
                        alert("保存成功！");
                        window.location.href = 'PeiXunYingJi.aspx';
                    }
                }
            });
        }
        //获取数据
        function btn_yjqk_Get(cid) {
            $("#HidID").val(cid);

            $.ajax({
                type: "Post",
                url: "PeiXunYingJi.aspx/YingJiQingKuang_Get",
                data: "{'_id':'" + cid + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    $("#ddl_yjqk_leibie").val(data.d[0] == null ? "" : data.d[0]);
                    $("#txt_yjqk_mingchen").val(data.d[1] == null ? "" : data.d[1]);
                    $("#txt_yjqk_renshu").val(data.d[2] == null ? "" : data.d[2]);

                    $("#btn_yjqk_Edit").show();
                    $("#btn_yjqk_Add").hide();
                    divshow("yjqk_div", "bg");
                }
            });
        }
        //编辑数据
        function btn_yjqk_Edit() {
            var txt_yjqk_mingchen = $("#txt_yjqk_mingchen").val();
            var txt_yjqk_renshu = $("#txt_yjqk_renshu").val();
            var ddl_yjqk_leibie = $("#ddl_yjqk_leibie").val();
            var cid = $("#HidID").val();

            $.ajax({
                type: "Post",
                url: "PeiXunYingJi.aspx/YingJiQingKuang_Edit",
                data: "{'_id':'" + cid + "','txt_yjqk_mingchen':'" + txt_yjqk_mingchen + "','txt_yjqk_renshu':'" + txt_yjqk_renshu + "','ddl_yjqk_leibie':'" + ddl_yjqk_leibie + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "OK") {
                        alert("保存成功！");
                        window.location.href = 'PeiXunYingJi.aspx';
                    }
                }
            });
        }

        //添加数据
        function btn_pxqk_Add() {

            var txt_pxqk_peixunxiangmu = $("#txt_pxqk_peixunxiangmu").val();
            var txt_pxqk_riqi = $("#txt_pxqk_riqi").val();
            var ddl_pxqk_leibie = $("#ddl_pxqk_leibie").val();
            var hdn_pxqk_filepath = $("#hdn_pxqk_filepath").val();

            var hdn_useDate = $("#hdn_useDate").val();
            var hdn_currentClassID = $("#hdn_currentClassID").val();
            var hdn_currentGroppID = $("#hdn_currentGroppID").val();

            var _ribaobianhao = hdn_useDate + "," + hdn_currentClassID + "," + hdn_currentGroppID + ",";

            $.ajax({
                type: "Post",
                url: "PeiXunYingJi.aspx/PeiXunQingKuang_Add",
                data: "{'txt_pxqk_peixunxiangmu':'" + txt_pxqk_peixunxiangmu + "','txt_pxqk_riqi':'" + txt_pxqk_riqi + "','ddl_pxqk_leibie':'" + ddl_pxqk_leibie + "','hdn_pxqk_filepath':'" + hdn_pxqk_filepath + "','_ribaobianhao':'" + _ribaobianhao + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "ok") {
                        alert("保存成功！");
                        window.location.href = 'PeiXunYingJi.aspx';
                    }
                }
            });
        }
        //获取数据
        function btn_pxqk_Get(cid) {
            $("#HidID").val(cid);

            $.ajax({
                type: "Post",
                url: "PeiXunYingJi.aspx/PeiXunQingKuang_Get",
                data: "{'_id':'" + cid + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    $("#ddl_pxqk_leibie").val(data.d[0] == null ? "" : data.d[0]);
                    $("#txt_pxqk_peixunxiangmu").val(data.d[1] == null ? "" : data.d[1]);
                    $("#txt_pxqk_riqi").val(data.d[2] == null ? "" : data.d[2]);
                    
                    $("#btn_pxqk_Edit").show();
                    $("#btn_pxqk_Add").hide();
                    divshow("pxqk_div", "bg");
                }
            });
        }
        //编辑数据
        function btn_pxqk_Edit() {
            var txt_pxqk_peixunxiangmu = $("#txt_pxqk_peixunxiangmu").val();
            var txt_pxqk_riqi = $("#txt_pxqk_riqi").val();
            var ddl_pxqk_leibie = $("#ddl_pxqk_leibie").val();
            var cid = $("#HidID").val();

            $.ajax({
                type: "Post",
                url: "PeiXunYingJi.aspx/PeiXunQingKuang_Edit",
                data: "{'_id':'" + cid + "','txt_pxqk_peixunxiangmu':'" + txt_pxqk_peixunxiangmu + "','txt_pxqk_riqi':'" + txt_pxqk_riqi + "','ddl_pxqk_leibie':'" + ddl_pxqk_leibie + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "OK") {
                        alert("保存成功！");
                        window.location.href = 'PeiXunYingJi.aspx';
                    }
                }
            });
        }

        function click_Download(yjqk_id)
        {
            var url = $("#ddl_yjqk_" + yjqk_id).val();
            if (url != null && url != "") {
                $("#frame_download").attr("src", "../../UpFile/" + url);
            }
        }
    </script>
</head>
<body style="background-color:#E5F1FD">
    <input type="hidden" id="HidID" />
    <form runat="server">
        <%
            string useDate = null;
            string currentClassID = null;
            string currentGroppID = null;
            if (Session["useDate"] != null)
                useDate = Session["useDate"].ToString();
            if (Session["ClassID"] != null)
                currentClassID = Session["ClassID"].ToString();
            if (Session["GroppID"] != null)
                currentGroppID = Session["GroppID"].ToString();
        %>
        <input type="hidden" id="hdn_useDate" value='<%=useDate%>' />
        <input type="hidden" id="hdn_currentClassID" value='<%=currentClassID%>' />
        <input type="hidden" id="hdn_currentGroppID" value='<%=currentGroppID%>' />
        <table width="500">
            <tr>
                <td colspan="2">培训应急汇报：
                    <input type="radio" name="rbm" value="是" checked="checked"/>是
	                <input type="radio" name="rbm" value="否" />否
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <table width="100%" id="table_yjqk">
                        <tr>
                            <td>
                                <table width="100%">
                                    <tr>
                                        <td align="left" style="color:darkblue">应急情况</td>
                                        <td width="84" align="right">
                                            <input type="button" id="Button1" onclick="$('#btn_yjqk_Edit').hide(); divshow('yjqk_div', 'bg')" class="input_btn_a" value="新增" />
                                        </td>
                                        <td width="84" align="right">
                                            <input type="button" id="Button2" onclick="" class="input_btn_a" value="应急计划" />
                                        </td>
                                        <td width="120" align="right">
                                            &nbsp;
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td align="center">
                                <table width="100%" border="1" cellpadding="0" cellspacing="0" class="swxx_table">
                                    <thead>
                                        <tr>
                                            <td align="center">名称
                                            </td>
                                            <td align="center">人数
                                            </td>
                                            <td align="center">类别
                                            </td>
                                            <td align="center">选择文档
                                            </td>
                                            <td align="center">操作
                                            </td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <asp:Repeater ID="rpt_yingjiqingkuang" runat="server" OnItemCommand="rpt_yingjiqingkuang_ItemCommand">
                                            <ItemTemplate>
                                                <tr>
                                                    <td align="center">
                                                        <%#Eval("mingchen")%>
                                                    </td>
                                                    <td align="center">
                                                        <%#Eval("renshu")%>
                                                    </td>
                                                    <td align="center">
                                                        <%#Eval("leibie")%>
                                                    </td>
                                                    <td>
                                                        <select id="ddl_yjqk_<%#Eval("id") %>">
                                                            <option value="<%#Eval("yuan") %>">
                                                                应急预案
                                                            </option>
                                                            <option value="<%#Eval("jilu") %>">
                                                                应急记录
                                                            </option>
                                                            <option value="<%#Eval("zongjie") %>">
                                                                应急总结
                                                            </option>
                                                        </select>
                                                    </td>
                                                    <td align="center">
                                                        <img alt="" src="../../../Images/download.gif" style="cursor: pointer;" onclick="click_Download('<%#Eval("id")%>')"/>
                                                        <img alt="" src="../../Images/file.gif" onclick="btn_yjqk_Get('<%#Eval("id")%>')" style="cursor: pointer;" />
                                                        <asp:ImageButton ID="img_btn" runat="server" ImageUrl="../../Images/trash.gif" OnClientClick="return confirm('确认删除？');"
                                                            CommandArgument='<%#Eval("id")%>' CommandName="del" />
                                                    </td>
                                                </tr>
                                            </ItemTemplate>
                                        </asp:Repeater>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <table width="100%" id="table_pxqk">
                        <tr>
                            <td>
                                <table width="100%">
                                    <tr>
                                        <td style="color:darkblue">培训情况</td>
                                        <td width="84" align="left">
                                        <input type="button" id="Button3" onclick="$('#btn_pxqk_Edit').hide(); divshow('pxqk_div', 'bg')" class="input_btn_a" value="新增" />
                                        </td>
                                        <td width="84" align="right">
                                            &nbsp;
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td align="center">
                                <table width="100%" border="1" cellpadding="0" cellspacing="0" class="swxx_table">
                                    <thead>
                                        <tr>
                                            <td align="center">培训项目
                                            </td>
                                            <td align="center">日期
                                            </td>
                                            <td align="center">类别
                                            </td>
                                            <td align="center">培训文档
                                            </td>
                                            <td align="center">操作
                                            </td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <asp:Repeater ID="rpt_peixunqingkuang" runat="server" OnItemCommand="rpt_peixunqingkuang_ItemCommand">
                                            <ItemTemplate>
                                                <tr>
                                                    <td>
                                                        <%#Eval("peixunxiangmu")%>
                                                    </td>
                                                    <td align="center">
                                                        <%#Eval("riqi","{0:yyyy-MM-dd}")%>
                                                    </td>
                                                    <td align="center">
                                                        <%#Eval("leibie")%>
                                                    </td>
                                                    <td>
                                                        <%# formatfilename(Eval("wendang").ToString())%>
                                                    </td>
                                                    <td align="center">
                                                        <img alt="" src="../../Images/file.gif" onclick="btn_pxqk_Get('<%#Eval("id")%>')" style="cursor: pointer;" />
                                                        <asp:ImageButton ID="img_btn" runat="server" ImageUrl="../../Images/trash.gif" OnClientClick="return confirm('确认删除？');"
                                                            CommandArgument='<%#Eval("id")%>' CommandName="del" />
                                                    </td>
                                                </tr>
                                            </ItemTemplate>
                                        </asp:Repeater>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </form>
    <!--弹出层背景-->
    <div id="bg" class="bg">
    </div>
    <!--弹出层应急情况-->
    <div id="yjqk_div" class="center_div" style="width: 290px; height: 300px; padding: 0px; margin-top: -100px;margin-left: 1px;">
        <div class="div_0207" style="width: 289px; height: 100%; margin: 0px;">
            <h1>
            <img alt="应急情况" src="../../Images/cp_h1_03.gif" />添加应急情况</h1>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td width="65" height="40" align="right">名称：
                    </td>
                    <td width="110">
                        <input type="text" id="txt_yjqk_mingchen" class="input_bg" />
                    </td>
                </tr>
                <tr>
                    <td width="65" align="right">人数：
                    </td>
                    <td width="110">
                        <input type="text" id="txt_yjqk_renshu" class="input_bg" />
                    </td>
                </tr>
                <tr>
                    <td align="right">类别：
                    </td>
                    <td>
                        <select id="ddl_yjqk_leibie">
                            <option value="火灾">火灾</option>
                            <option value="防盗">防盗</option>
                            <option value="绿化虫害">绿化虫害</option>
                            <option value="突发疾病">突发疾病</option>
                            <option value="人身伤害">人身伤害</option>
                            <option value="食物中毒">食物中毒</option>
                            <option value="燃气泄漏">燃气泄漏</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td align="left">上传应急预案：
                    </td>
                    <td>
                        <input type="hidden" id="hdn_yjqk_yuan_filepath"/>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="right">
                        <input type="file" id="Imgfile_yuan" style="height:22px; vertical-align:middle;" />
                    </td>
                </tr>
                <tr>
                    <td align="left">上传应急记录：
                    </td>
                    <td>
                        <input type="hidden" id="hdn_yjqk_jilu_filepath"/>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="right">
                        <input type="file" id="Imgfile_jilu" style="height:22px; vertical-align:middle;" />
                    </td>
                </tr>
                <tr>
                    <td align="left">上传应急总结：
                    </td>
                    <td>
                        <input type="hidden" id="hdn_yjqk_zongjie_filepath"/>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="right">
                        <input type="file" id="Imgfile_zongjie" style="height:22px; vertical-align:middle;" />
                    </td>
                </tr>
            </table>
            <table width="100%">
                <tr>
                    <td height="30" align="right">
                        <input type="button" id="btn_yjqk_Add" onclick="btn_yjqk_Add()" class="input_btn_a" value="提交" />
                        <input type="button" id="btn_yjqk_Edit" onclick="btn_yjqk_Edit()" class="input_btn_a" value="提交" />
                    </td>
                    <td>
                        <input type="button" id="but_Close" onclick='divhidel("yjqk_div", "bg")' class="input_btn_a"
                            value="关闭" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <!--弹出层应急情况   结束-->

    <!--弹出层培训情况-->
    <div id="pxqk_div" class="center_div" style="width: 400px; height: 200px; padding: 0px; margin-top: -100px;margin-left: 1px;">
        <div class="div_0207" style="width: 398px; height: 100%; margin: 0px;">
            <h1>
                <img src="../../Images/cp_h1_03.gif" />添加培训情况</h1>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td width="65" height="40" align="right">培训项目：
                    </td>
                    <td width="110">
                        <input type="text" class="input_bg" id="txt_pxqk_peixunxiangmu" />
                    </td>
                </tr>
                <tr>
                    <td width="65" align="right">日期：
                    </td>
                    <td width="110">
                        <input type="text" class="input_bg" id="txt_pxqk_riqi" />
                    </td>
                </tr>
                <tr>
                    <td align="right">类别：
                    </td>
                    <td>
                        <select id="ddl_pxqk_leibie">
                            <option value="一级培训">一级培训</option>
                            <option value="二级培训">二级培训</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td align="right">上传文档：
                    </td>
                    <td>
                        <input type="hidden" id="hdn_pxqk_filepath"/>
                    </td>
                </tr>
                <tr>
                    <td align="center" colspan="2">
                        <input type="file" id="Imgfile_peixunqingkuang" style="height:22px; vertical-align:middle;" />
                    </td>
                </tr>
            </table>
            <table width="100%">
                <tr>
                    <td height="30" align="right">
                        <input type="button" id="btn_pxqk_Add" onclick="btn_pxqk_Add()" class="input_btn_a" value="提交" />
                        <input type="button" id="btn_pxqk_Edit" onclick="btn_pxqk_Edit()" class="input_btn_a" value="提交" />
                    </td>
                    <td>
                        <input type="button" id="Button6" onclick='divhidel("pxqk_div", "bg")' class="input_btn_a"
                            value="关闭" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <!--弹出层培训情况   结束-->
    <iframe style="display:none;" id="frame_download" name="frame_download"></iframe>
</body> 
</html>
